// Construct Clean Rates of Return


//----------------------------------------------
//----------------------------------------------
//----------------------------------------------
//----------------------------------------------
//Look at average growth rates of returns between each year and 25 years later. 
//This repeats some growth episodes but is independent of starting year!


//Load long run returns Data

use "$base/InputData/longRunReturnsData.dta", clear
sort countrycode year


encode countrycode, gen(cc)
xtset cc year



//Calculate real returns annual and generational
foreach i in "e" "b" "t"{
gen `i'rirA=(`i'returns/l.`i'returns)-1
gen `i'rirG=(`i'returns/l25.`i'returns)^(1/25)-1

}

drop cc
sort countrycode year

save "$base/Outputs/Data/longRunReturnsData.dta", replace
